Skip to content

Conversation

@zhumin8
Copy link
Contributor

@zhumin8 zhumin8 commented Mar 18, 2025

This change allow generator to generate for a specified api-path. When "--api-path" is not specified, fallback to "--library-names", and behavior for existing command usages should not change.

For now, api-path should only take in path to api/version, e.g. google/cloud/functions/v2

--
Manual tests

python library_generation/cli/entry_point.py generate --output=/path/to/empty/output --generation-input=/path/to/gen-input --api-root=/path/to/googleapis --api-path=google/cloud/alloydb/v1

generate output

├── google-cloud-alloydb
│   ├── pom.xml                                                                            
│   ├── src                                                                                
│   │   ├── main                                                                           
│   │   │   ├──......                                                
│   │   │   │    └── v1  
├── google-cloud-alloydb-bom
├── grpc-google-cloud-alloydb-v1
├── owlbot.py
├── pom.xml
├── proto-google-cloud-alloydb-v1
├── README.md
└── samples

@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Mar 18, 2025
@zhumin8 zhumin8 marked this pull request as ready for review March 24, 2025 21:22
Copy link
Contributor

@diegomarquezp diegomarquezp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR. It will make local development much easier (no need to modify the gen config yaml anymore).

I left a couple of nits and a minor question.

seen_library_names[library_name] = library.name_pretty

@staticmethod
def from_yaml(path_to_yaml: str) -> "GenerationConfig":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any logical change in this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, only moved so it can be called as GenerationConfig.from_yaml(). Provides better readability imo.

show_default=True,
help="""
Path within the API root (e.g. googleapis) to the API to
generate/build/configure etc. This is expected to be a major-versioned
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference of major-versioned and versioned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the term versions are used in a couple of confusing ways. major-versioned refers to the cases where there is a proto-path for it, and we produce a module in Java. (there is also an "api-version" that is specified within proto, for details go/clientlibs-api-versioning-proposal)

""",
)
@click.option(
"--api-path",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this parameter is overlap with library-names and it's fine-gained than it.

Do you plan to remove library-names later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there are overlap. In short term, will support both so current workflow can work unchanged.
After we onboard fully to 1PP, will evaluate and remove redundant options if needed.

return proto_path


def ends_with_version(proto_path: str) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a setter method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I get what you are referring by "setter method"? If it is a typo and you are asking about this method, it is used here to account for cases where dependencies like /type are included as proto-path (e.g., accesscontextmanager)

That said, the exact logic may change in followup PRs as we have a slight change in design, and I have an related incoming PR that may change GenerationConfig.libraries from a list to dict.

@zhumin8 zhumin8 enabled auto-merge (squash) April 2, 2025 16:32
@diegomarquezp
Copy link
Contributor

Thanks for the patience!#3726 has been merged and merging main should fix the generation IT.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 2, 2025

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 2, 2025

Quality Gate Passed Quality Gate passed for 'java_showcase_integration_tests'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@zhumin8 zhumin8 merged commit aef1bed into main Apr 2, 2025
52 of 53 checks passed
@zhumin8 zhumin8 deleted the allow-api-path branch April 2, 2025 21:07
lqiu96 pushed a commit that referenced this pull request Jun 10, 2025
…i/majorversion (#3712)

This change allow generator to generate for a specified api-path. When
"--api-path" is not specified, fallback to "--library-names", and
__behavior for existing command usages should not change__.

For now, api-path should only take in path to api/version, e.g.
google/cloud/functions/v2
lqiu96 pushed a commit that referenced this pull request Aug 21, 2025
…i/majorversion (#3712)

This change allow generator to generate for a specified api-path. When
"--api-path" is not specified, fallback to "--library-names", and
__behavior for existing command usages should not change__.

For now, api-path should only take in path to api/version, e.g.
google/cloud/functions/v2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants